package com.robb19y.rgbdscanner.viewer;

import java.util.ArrayList;

import org.OpenNI.GeneralException;

import com.robb19y.rgbdscanner.core.RGBDData;
import com.robb19y.rgbdscanner.core.RGBDFilter;
import com.robb19y.rgbdscanner.core.RGBDSensor;
import com.robb19y.rgbdscanner.icp.ICPAlgorithm;

public class Scanner {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			RGBDSensor camera = new RGBDSensor();
			camera.setTimeout(300);
			JVRep vrep = new JVRep();
			vrep.startSimulation();
			camera.start();
			Thread.sleep(6000);
			RGBDFilter filter = new RGBDFilter();

			filter.setPixelStep(5);
			filter.setMaxDist(4000);
			ICPAlgorithm icp = new ICPAlgorithm();
			
			RGBDData[][] model = camera.getRgbdData();
			ArrayList<RGBDData> listModel;
			ArrayList<RGBDData> listData;
			listModel = filter.filter(model);
			vrep.addPointCloud(listModel);
			
			RGBDData[][] data;
			
			for(int i = 0; i < 50; i++){
				data = camera.getRgbdData();
				listData = filter.filter(data);	
				icp.pointCloudRegistration(listModel, listData);
				vrep.addPointCloud(listData);
				
				listModel = listData;
			}
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}

}
